<!DOCTYPE html>
<html>
  <head>
    <title></title>
	
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
    
    <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
	<script src="http://apps.bdimg.com/libs/jquery/1.11.3/jquery.min.js"></script>
  </head>
  
  <body>
    <DIV>
    	<span id="ifin"></span>
    </DIV>
  </body>
</html>

<script type="text/javascript">


	var url = location.href.split('#')[0];

	var start = url.indexOf("code=");

	var end = url.indexOf("&state");

	var code = url.substring(start+5,end);

$(function () {
	//方法二：
	(function ($) {
	   $.getUrlParam = function (name) {
	       var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
	       var r = window.location.search.substr(1).match(reg);
	       if (r != null) return unescape(r[2]); return null;
	  }
	   })(jQuery);
		
 	  var ifin = $.getUrlParam('ifin');
	  if(ifin==1){
		  $(function(){
			  document.title='签到页面';
			  ifin2();
			  $("#ifin").text("正在签到。。。。。");
			});
	  }else if(ifin==0){
		  $(function(){
			  document.title='签出页面';
			  ifin2();
			  $("#ifin").text("正在签出。。。。。");
			  
			});
	  }
	
	  
	  function ifin2(){
		  $.ajax({
		 	   async: false,
				cache:false,
				type: 'POST',
				url: "WeChatAction_sign.action",
				data:{
					ifin:ifin,
					code:code
				},
				dataType:"json",
				success: function (data) {
					msg = eval("(" + data + ")");
					/* switch msg.msg:
						case 0:
							alert("对不起，您还没有注册，没有权限进行操作！！");
							setTimeout(function () {
							   	WeixinJSBridge.call("closeWindow");
							 }, 1000);
							break;
						case 1:
							alert("签到成功！！");
							setTimeout(function () {
							   	WeixinJSBridge.call("closeWindow");
							 }, 2000);
							break;
						case 2: */
							
					if(msg.msg==1){
						alert("签到成功！！");
						setTimeout(function () {
						   	WeixinJSBridge.call("closeWindow");
						 }, 2000);
					} else if(msg.msg==0) {
						alert("对不起，您还没有注册，没有权限进行操作！！");
						setTimeout(function () {
						   	WeixinJSBridge.call("closeWindow");
						 }, 2000);
					} else if(msg.msg==3) {
						alert("对不起，你已经签到，不可重复签到！");
						setTimeout(function () {
						   	WeixinJSBridge.call("closeWindow");
						 }, 2000);
					} else if(msg.msg==4) {
						alert("对不起，你已经签出，不可重复签出！");
						setTimeout(function () {
						   	WeixinJSBridge.call("closeWindow");
						 }, 2000);
					} else if(msg.msg==2) {
						alert("签出成功！！");
						setTimeout(function () {
						   	WeixinJSBridge.call("closeWindow");
						 }, 2000);
					} else if(msg.msg==5) {
						alert("你还没有通过审核，无法进行该操作！！");
						setTimeout(function () {
						   	WeixinJSBridge.call("closeWindow");
						 }, 2000);
					}
				  },
				   error: function () {
				      alert("出现异常！！");
				}
			});
	  }
	  
	  
   
})

/* function close(){
		alert("aaa");
		WeixinJSBridge.call("closeWindow");
} */
		
</script>
